var product = new Vue({
	el: "#app",
	data: {
		s5,
		storeId: '',
		store: '',
	},
	computed: {

	},
	watch: {

	},
	created: function() {
		if (document.URL.indexOf("?") < 0) return; //获取当前url地址,如果没参数.直接返回
		var str = document.URL.split("?")[1];
		var obj = {};
		var arr;
		//当只有一个参数传过来时
		if (str.indexOf("&") < 0) {
			if (str.indexOf("=") < 0) return;
			arr = str.split("=");
			obj[arr[0]] = arr[1];
			this.storeId = obj
			return obj;
		}

	},
	mounted: function() {
		this.getStore()
	},
	methods: {
		getStore() {
			var that = this
			s5.initData({
				url: '/store-detail',
				type: "post",
				data: {
					store_id: this.storeId.id
				}
			}, (res) => {
				var data = JSON.parse(res)
				that.store = data.data
			})
		},
		openLocation() {
			var that = this;
			wx.openLocation({
				latitude:parseFloat(that.store.lat),
				longitude:parseFloat(that.store.lng),
				name: that.store.title,
				infoUrl:'',
				address: that.store.address,
				scale: 14,
				success: function(res) {
					console.log(res)
					// alert(res)
				},
				fail:function(res){
					alert(res.errMsg)
				}
			});
		}
	}
})
